package icasue.tools.compile.compilers.jfobjs;

import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import java.net.URI;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2020/12/3 下午3:55
 * @UpdateDate:
 * @Description:
 */
public abstract class AbstractJavaFileObjects extends SimpleJavaFileObject {

    /**
     * This buffer is used for store java class objects, which generic by compiler.
     */
    public static final Map<String, JavaFileObject> objectsGeneric = new ConcurrentHashMap<>();

    /**
     * Construct a SimpleJavaFileObject of the given kind and with the
     * given URI.
     *
     * @param uri  the URI for this file object
     * @param kind the kind of this file object
     */
    protected AbstractJavaFileObjects(URI uri, Kind kind) {
        super(uri, kind);
    }


    /**
     * Through ClassLoader to load class, will read byte code generic by system's compiler.
     * @return
     */
    public abstract byte[] getCompiledBytes();

}
